package com.jprocms.module.cms.convert.vote;

import com.jpro.framework.common.pojo.PageResult;
import com.jprocms.module.cms.controller.admin.vote.vo.VoteCreateReqVO;
import com.jprocms.module.cms.controller.admin.vote.vo.VoteExcelVO;
import com.jprocms.module.cms.controller.admin.vote.vo.VoteRespVO;
import com.jprocms.module.cms.controller.admin.vote.vo.VoteUpdateReqVO;
import com.jprocms.module.cms.controller.admin.voteitem.vo.VoteItemCreateReqVO;
import com.jprocms.module.cms.convert.voteitem.VoteItemConvert;
import com.jprocms.module.cms.dal.dataobject.vote.VoteDO;
import com.jprocms.module.cms.dal.dataobject.voteitem.VoteItemDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 投票 Convert
 *
 * @author jprocms
 */
@Mapper
public interface VoteConvert {

    VoteConvert INSTANCE = Mappers.getMapper(VoteConvert.class);

    VoteDO convert(VoteCreateReqVO bean);

    default VoteDO convertMore(VoteCreateReqVO bean) {
        VoteDO voteDO = convert(bean);
        voteDO.setItems(VoteItemConvert.INSTANCE.convertListForCreate(bean.getItems()));
        return voteDO;
    }

    VoteDO convert(VoteUpdateReqVO bean);

    default VoteDO convertMore(VoteUpdateReqVO bean) {
        VoteDO voteDO = convert(bean);
        voteDO.setItems(VoteItemConvert.INSTANCE.convertListForUpdate(bean.getItems()));
        return voteDO;
    }

    default List<VoteItemDO> createVOToItemDOS(List<VoteItemCreateReqVO> vos) {
        return VoteItemConvert.INSTANCE.convertListForCreate(vos);
    }

    VoteRespVO convert(VoteDO bean);

    List<VoteRespVO> convertList(List<VoteDO> list);

    PageResult<VoteRespVO> convertPage(PageResult<VoteDO> page);

    List<VoteExcelVO> convertList02(List<VoteDO> list);

}
